package openones.samples.dataform.biz;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;

import openones.samples.dataform.entity.User;

/**
 * Demo business class.
 * @author Thach Le
 *
 */
public class DataFormBiz {
    static final Logger LOG = Logger.getLogger("DataFormBiz");
    static Map<String, User> userMap = new HashMap<String, User>();
    
    /**
     * Add user.
     * @param user
     */
    public void addUser(User user) {
        userMap.put(user.getUsername(), user);
        LOG.debug("Added a new user '" + user + "'. Total " + userMap.size() + " users.");
    }
    
    /**
     * Get all users.
     * @return
     */
    public Collection<User>  getUsers() {
        return userMap.values();
    }
}
